import java.util.Arrays;

public class TestDemo2 {


    public static void main(String[] args) {
        int[] array1 = {10,2,4,7,5};
        for (int i = 0; i < array1.length; i++) {
            //if(i == 3){
            //    array1[i] *= 9;
            //}
            System.out.print(array1[i]+" ");
        }
        System.out.println();
        System.out.println("========for each 增强for循环=======");
        for (int x : array1){
            System.out.print(x+" ");
        }
        System.out.println();
        //for(表达式1 : 表达式2){
        //
        //}
        System.out.println("=======使用操作数组的工具类=======");
        //把传入的东西以字符串的形式进行输出
        String ret = Arrays.toString(array1);
        System.out.println(ret);
    }

    public static void main2(String[] args) {
        int[] array1 = {10,2,4,7,5};
        System.out.println(array1.length);
        System.out.println(array1[0]);
        //System.out.println(array1[5]);不能访问越界
        array1[0] = 99;
        System.out.println(array1[0]);

    }

    public static void main1(String[] args) {
        int score1 = 10;
        int score2 = 10;
        int score3 = 10;
        int score4 = 10;

        int[] array1 = {10,2,4,7,23,5};//定义且同时初始化了一个数组，这个数组长度是6 数据分别是10，2，4，7,23，5
        //array1 = {10,2,4,58,68,87};不行
        array1[3] = 58;

        int[] array2 = new int[5];//定义一个数组，数组长度是10，没有初始化，默认值是0
        array2[0] = 9;

        int[] array3 = new int[]{1,2,3,4,5};
        array3 = new int[]{1,2,3,4,6};

        //int array[] = {10,2,4,23,5};不建议

        System.out.println(array3.length);
        System.out.println(array3[0]);

        int[] array11;
        //array11 = {10,3,4,5,6,7};error 省略格式的情况下 都不能分开写
        array11 = new int[]{10,3,4,5,6,7};
    }
}